package com.casic.ops.controller.pipeline;

import com.casic.ops.annotation.IgnoreLog;
import com.casic.ops.entity.request.pipeline.PipelineLoggerPageRequest;
import com.casic.ops.entity.request.pipeline.PipelineLoggerRequest;
import com.casic.ops.entity.vo.pipeline.response.Response;
import com.casic.ops.service.api.pipeline.PipelineLoggerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 流水线执行记录controller
 * @author cww
 * @date 2022-05-05 11:31:43
 */
@RestController
@Api(tags = "流水线执行记录模块",description = "包含新增/列表/删除")
@RequestMapping("ops/api/pipeline/logger")
public class PipelineLoggerController {
    @Resource
    private PipelineLoggerService pipelineLoggerService;

    @DeleteMapping("/batch/delete")
    @ApiOperation(value = "删除",httpMethod = "DELETE")
    public Response delete(@RequestBody Long[] ids){
        return pipelineLoggerService.delete(ids);
    }

    @DeleteMapping("/delete")
    public Response deleteOne(@RequestParam("id") long id){
        return pipelineLoggerService.deleteOne(id);
    }

    @PostMapping("/page")
    @ApiOperation(value = "列表",httpMethod = "GET")
    public Response page(@RequestBody PipelineLoggerPageRequest pipelineLoggerPageRequest){
        return pipelineLoggerService.page(pipelineLoggerPageRequest);
    }

    @GetMapping("/list")
    @ApiOperation(value = "列表",httpMethod = "GET")
    public Response list(@RequestParam("PipelineUuid") String pipelineUuid){
        return pipelineLoggerService.list(pipelineUuid);
    }

    @GetMapping("/info")
    @ApiOperation(value = "详情",httpMethod = "GET")
    public Response info(@RequestParam("id") long id){
        return pipelineLoggerService.getById(id);
    }

    @PutMapping("/update")
    @ApiOperation(value = "更新",httpMethod = "PUT")
    public Response update(@RequestBody PipelineLoggerRequest pipelineLoggerRequest){
        return pipelineLoggerService.update(pipelineLoggerRequest);
    }

    /**
     * 应用流水线统计 视图
     */
    @GetMapping("/view")
    public Response appReleaseStatisticsView(@RequestParam("pipelineUuid") String pipelineUuid ) {
        return pipelineLoggerService.pipelineLoggerStatisticView(pipelineUuid);
    }

    /**
     * 应用流水线统计 指标
     */
    @GetMapping("/metrics")
    public Response appReleaseStatisticsMetrics(@RequestParam("pipelineUuid") String pipelineUuid) {
        return pipelineLoggerService.pipelineLoggerStatisticMetrics(pipelineUuid);
    }

    /**
     * 应用流水线统计 折线图
     */
    @GetMapping("/chart")
    public Response appReleaseStatisticsChart(@RequestParam("pipelineUuid") String pipelineUuid) {
        return pipelineLoggerService.pipelineLoggerStatisticChart(pipelineUuid);
    }
}
